﻿using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using NLite.Collections;
using NLite.Data.Dialect;
using NLite.Data.Driver;
using System.Data;
using NLite.Data.Driver.Internal;
using NLite.Data.Schema;
using NLite.Data.Schema.Internal;

namespace NLite.Data
{
    public static class DbConfig
    {
        static DbConfig()
        {
            Driver = new SqlClientDriver();
            Dialect = new MsSql2000Dialect();
            SupportsParameterInSql = true;
        }

        public static IDriver Driver { get; private set; }
        public static Dialect.Dialect Dialect { get; private set; }
        public static ISchemaManager SchemaManager { get; private set; }

        public const int DefaultLength = 255;
        public const int DefaultPrecision = 19;
        public const int DefaultScale = 2;

        public static bool SupportsParameterInSql { get; set; }

        public static void Config(IDriver driver,Dialect.Dialect dialect )
        {
            Driver = driver;
            Dialect = dialect;
            SchemaManager = new SchemaManager(driver);
            if (SchemaManager.Keywords.Length > 0)
            {
                foreach (var keyword in SchemaManager.Keywords)
                    Dialect.Keywords.Add(keyword);
            }
        }

    }

}
